"""
@Melody

@TSL is dying


#晦气到了呢
"""
import os
import sys
import ctypes
import time
import threading
import random
import turtle
# import math

def draw_Melody():
    # init
    turtle.resetscreen()
    turtle.title("Melody")
    turtle.goto(0, 0)
    'turtle.speed(0)'
    
    time.sleep(2)
    TSL_waiting_timeout_value = 3
    for _ in range(TSL_waiting_timeout_value):
        turtle.title("Melody 将在 " + str(TSL_waiting_timeout_value - _) + " 秒后到达战场,请做好准备...")    
        time.sleep(1)

    turtle.title("Melody's boyfriend")

    turtle.pu()
    turtle.lt(90)
    turtle.fd(20)
    turtle.pd()
    turtle.fd(30)
    turtle.lt(90)
    turtle.circle(50, 90)
    turtle.pu()
    turtle.goto(0, 0)
    turtle.seth(0)
    turtle.lt(90)
    turtle.fd(50)
    turtle.rt(270)
    turtle.pd()
    turtle.circle(50, -90)

    turtle.title("is")

    turtle.pu()
    turtle.goto(0, 0)
    turtle.seth(0)
    turtle.lt(90)
    turtle.fd(20)
    turtle.pd()
    turtle.lt(90)
    turtle.circle(30, 90)

    turtle.title("fucking TSL")

    turtle.pu()
    turtle.goto(0, 0)
    turtle.seth(90)
    turtle.fd(20)
    turtle.pd()
    turtle.rt(90)
    turtle.circle(-30, 90)

    turtle.title("so they are")

    # LeftEye_top
    turtle.pu()
    turtle.goto(0, 0)
    turtle.seth(180)
    turtle.fd(10)
    turtle.pd()
    turtle.fd(25)
    # RightEye_top
    turtle.pu()
    turtle.goto(0, 0)
    turtle.seth(0)
    turtle.fd(10)
    turtle.pd()
    turtle.fd(25)

    turtle.title("really")

    # LeftEye_bottom
    turtle.pu()
    turtle.goto(0, -15)
    turtle.seth(180)
    turtle.fd(10)
    turtle.pd()
    turtle.fd(30)
    # RightEye_bottom
    turtle.pu()
    turtle.goto(0, -15)
    turtle.seth(0)
    turtle.fd(10)
    turtle.pd()
    turtle.fd(30)

    turtle.title("unlucky")

    # LeftWhiteEye
    turtle.pu()
    turtle.goto(-20, 0)
    turtle.seth(180)
    turtle.pd()
    turtle.circle(5, 360)
    # RightWhiteEye
    turtle.pu()
    turtle.goto(20, 0)
    turtle.seth(0)
    turtle.pd()
    turtle.circle(-5, 360)

    turtle.title("Unlucky lose girlfriend")

    # nose
    turtle.pu()
    turtle.goto(0, -10)
    turtle.seth(-90)
    turtle.pd()
    turtle.fd(20)

    turtle.title("Unlucky!!!")

    # Market_top
    turtle.pu()
    turtle.lt(90)
    turtle.fd(-30)
    turtle.pd()
    turtle.fd(60)

    turtle.title("Bad luck")

    # Face
    turtle.pu()
    turtle.goto(-30, -0)
    turtle.seth(-90)
    turtle.pd()
    turtle.fd(40)
    turtle.circle(30, 180)
    turtle.fd(40)

    turtle.title("Officer~")

    # ===== BEGIN Market_main =====

    turtle.pu()
    turtle.goto(-25, -35)
    turtle.seth(0)
    turtle.pd()
    turtle.fd(50)

    turtle.pu()
    turtle.rt(90)
    turtle.fd(10)
    turtle.rt(90)
    turtle.fd(10)
    turtle.pd()
    turtle.fd(30)

    turtle.pu()
    turtle.lt(90)
    turtle.fd(10)
    turtle.lt(90)
    turtle.pd()
    turtle.fd(30)
    
    # ===== END Market_main =====

    turtle.title("Your computer was FUCKED by Melody" + " "*32 + "你的电脑被Melody晦气了!!")

def MelodyFucker():
    turtle.pu()
    turtle.goto(0, 200)
    turtle.seth(0)
    turtle.pd()
    turtle.write("Your computer was FUCKED by Melody")
    turtle.pu()
    turtle.goto(0, 210)
    turtle.seth(0)
    turtle.pd()
    turtle.write("你的电脑被Melody晦气了!!")
    turtle.pu()
    turtle.goto(0, 220)
    turtle.seth(0)
    turtle.pd()
    turtle.write("输入解锁马: ")
    time.sleep(4.99)
    # turtle.bye()
    UnlockKeyInputModule()

def UnlockKeyInputModule():
    keys = [ "FuckTSL", "TSLSM", "TSL", "2011", "NMSL", "PyTSL", "114514" ]
    while True:
        # turtle.bye()
        turtle.reset()
        key = turtle.textinput("Your computer was FUCKED by Melody", "输入解锁马: ")
        try:
            keys.index(key)
            ctypes.WinDLL('user32.dll').MessageBoxW(None, '解锁成功!', 'Melody Fucker', 0x40)
            turtle.bye()
            return
        except ValueError:
            if key == "" or key == None:
                ctypes.WinDLL('user32.dll').MessageBoxW(None, '搁这搁这呢', 'Melody Fucker', 0x10)
                continue
            ctypes.WinDLL('user32.dll').MessageBoxW(None, '搁这猜呢', 'Melody Fucker', 0x10)
            ctypes.WinDLL('user32.dll').MessageBoxW(None, '攒劲猜', 'Melody Fucker', 0x10)
    #

def crazy_error_TEACHERS():
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '竟然关掉??', 'TSL', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '你妈准你搞这些啊?', '翠翠', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '攒劲劳', '翠翠', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '再笑我让你哭', 'Amy', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '再哭我让你笑', 'Amy', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '再关我让你布置考场', 'Lily', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '关掉关掉一定要关掉', '关掉姐', 0x40)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '再不关掉这些', '关掉姐', 0x40)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '网络', '关掉姐', 0x40)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, 'TSL', 'TSL', 0x10)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '我看了这么久', '姗姗来迟', 0x40)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '我才发现', '姗姗来迟', 0x40)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, '我少写了个姗!!', '姗姗来迟', 0x40)
    ctypes.WinDLL('user32.dll').MessageBoxW(None, 'NM怎么都不提醒我?!', '姗姗来迟', 0x10)

def main():
    try:
        draw_Melody()
        MelodyFucker()
    except turtle.Terminator:
        crazy_error_TEACHERS()
        UnlockKeyInputModule()
        sys.exit(114514)
    turtle.done()
    UnlockKeyInputModule()

main()
